package com.api.dispose.enums;


import lombok.Getter;
import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 第三方平台类型枚举
 *
 * @author 李大牛家的牛 (scafel@163.com)
 * @createDate 2025/5/20-14:58
 * @description 第三方平台类型枚举
 **/
@Getter
public enum ThirdTypeEnums {

    WECHAT_APPLET(1, "微信小程序"),
    WECHAT_OFFICIAL_ACCOUNT(2, "微信公众号"),
    APPLE_APPLET(3, "苹果小程序"),
    ANDROID_APPLET(4, "安卓小程序"),
    QQ_APPLET(5, "QQ小程序"),
    ALIPAY_APPLET(6, "支付宝小程序"),
    BAIDU_APPLET(7, "百度小程序"),
    TOUTIAO_APPLET(8, "抖音小程序"),
    ANDROID_APP(9, "安卓APP"),
    IOS_APP(10, "苹果APP"),
    UNKONWN(0, "未知"),
    ;

    private static final Map<Integer, ThirdTypeEnums> codeToEnumMap = new ConcurrentHashMap<>();
    private static final ArrayList<EnumMap> enumMap = new ArrayList<>();

    static {
        for (ThirdTypeEnums type : ThirdTypeEnums.values()) {
            codeToEnumMap.put(type.getCode(), type);
            EnumMap map = new EnumMap();
            map.setKey(type.getCode());
            map.setLabel(type.getMessage());
            enumMap.add(map);
        }
    }

    private final int code;
    /**
     * 自定义描述
     **/
    private final String message;

    ThirdTypeEnums(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static ThirdTypeEnums getType(int code) {
        ThirdTypeEnums type = codeToEnumMap.get(code);
        if (type == null) {
            return ThirdTypeEnums.UNKONWN;
        }
        return type;
    }

    /**
     * 获取枚举类中所有的枚举值
     * @return Map
     */
    public static ArrayList<EnumMap> getEnumsMap() {
        return enumMap;
    }

}
